﻿Imports System.ComponentModel

<ToolboxItem(False)> <System.Serializable()> <System.ComponentModel.DefaultEvent("Click")> Public Class GWaveContextMenuItem
    Public Shadows Event Click(ByVal sender As Object, ByVal e As System.EventArgs)

#Region "UX Animations"
    Private Sub GWaveContextMenuItem_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click, Label1.Click, Panel1.Click, PictureBox1.Click
        Me.BackColor = Color.Gray
        Me.Focus()
        'Me.Label1.Text = Me.Parent.Name
        RaiseEvent Click(Me, e)
    End Sub

    Private Sub GWaveContextMenuItem_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus, Label1.LostFocus, Panel1.LostFocus, PictureBox1.LostFocus
        Me.BackColor = Color.White
    End Sub


    Private Sub GWaveContextMenuItem_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter, Label1.MouseEnter, Panel1.MouseEnter, PictureBox1.MouseEnter
        If Me.BackColor = Color.Gray Then Exit Sub
        Me.BackColor = Color.LightGray
    End Sub

    Private Sub GWaveContextMenuItem_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave, Label1.MouseLeave, Panel1.MouseLeave, PictureBox1.MouseLeave
        If Me.BackColor = Color.Gray Then Exit Sub
        Me.BackColor = Color.White
    End Sub
#End Region

#Region "UI Properties"
    Private Sub GWaveContextMenuItem_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Me.DesignMode Then
            Me.Text = Me.Name
        End If
    End Sub
    Protected Overrides Function SizeFromClientSize(ByVal clientSize As System.Drawing.Size) As System.Drawing.Size
        If CInt(Me.Parent.Size.Width) < CInt(clientSize.Width) Then
            Return MyBase.SizeFromClientSize(clientSize) : Exit Function
        End If

        Return MyBase.SizeFromClientSize(New Size(Parent.Width, clientSize.Height))
    End Function
    <Browsable(True)> <System.ComponentModel.Category("Appearance")> _
    Overrides Property Text() As String
        Get
            Return Label1.Text
        End Get
        Set(ByVal value As String)
            Label1.Text = value
        End Set
    End Property

    <Browsable(False)> _
    Public Overrides Property BackColor() As System.Drawing.Color
        Get
            Return MyBase.BackColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            MyBase.BackColor = value
        End Set
    End Property

    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
    Public Shadows ReadOnly Property Controls() As ControlCollection
        Get
            Return MyBase.Controls
        End Get
    End Property
#End Region
End Class
